package com.dyzx.hbb.modules.sys.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dyzx.hbb.common.config.MyLambdaQueryWrapper;
import com.dyzx.hbb.modules.sys.entity.SysApp;
import com.dyzx.hbb.modules.sys.mapper.SysAppMapper;
import com.dyzx.hbb.modules.sys.service.SysAppService;
import org.springframework.stereotype.Service;

/**
 * @author Administrator
 * @description 针对表【sys_app】的数据库操作Service实现
 * @createDate 2025-09-05 13:31:33
 */
@Service
public class SysAppServiceImpl extends ServiceImpl<SysAppMapper, SysApp>
        implements SysAppService {

    @Override
    public SysApp check(String platform, String versionCode) {
        int type = 0;
        switch (platform) {
            case "android":
                type = 1;
                break;
            case "iOS":
                type = 2;
                break;
            case "windows":
                type = 3;
                break;
            case "macOS":
                type = 4;
                break;
            case "linux":
                type = 5;
            case "fuchsia":
                type = 6;
                break;
            default:
                break;
        }
        MyLambdaQueryWrapper<SysApp> wrapper = new MyLambdaQueryWrapper<>();
        wrapper.gt(SysApp::getVersion, versionCode);
        wrapper.eq(SysApp::getType, type);
        wrapper.last("limit 1");
        return this.getOne(wrapper);
    }
}




